package com.new2i.action;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.new2i.aop.LoginInterceptor;
import com.new2i.model.DoctorEntity;
import com.new2i.model.UserEntity; 
import com.new2i.service.able.DoctorUserService;
import com.new2i.util.Collection2JsonUtil; 

/**
 * 医生管理用户视图控制器－接口
 * 
 * @author 2i
 * @since 2015/09/02
 */
@Controller
@RequestMapping("api/users")
public class DoctorUserApiAction extends BaseAction {
  
	@Autowired
	private DoctorUserService mDoctorUserService; 
	
	/**
	 * 医生手动创建新生儿用户
	 * 
	 * @author 2i
	 * @since 2015/09/03
	 * @param request
	 * @param response
	 * @param doctor
	 * @param user
	 * @param userNeo
	 */
	@LoginInterceptor
	@RequestMapping("/create")
	public void createDoctorUser(HttpServletRequest request, HttpServletResponse response, DoctorEntity doctor,
			UserEntity user) {
		HashMap<String, Object> map = mDoctorUserService.insertDoctorUser(doctor, user);
		String value = map == null ? Collection2JsonUtil.byErrInfo(321, "创建用户失败"): Collection2JsonUtil.byObject(map); 
		write2client(response, value); 
	}
}
